{% extends "admin/change_form.html" %}
{% load i18n %}
{% load satchmo_product_admin %}

{% block after_related_objects %}
{% if original %}
<fieldset class="module">
    <h2>{% trans "Product Subtypes" %}</h2>
    {% edit_subtypes original %}
</fieldset>
{% endif %}
{{ block.super }}
{% endblock %}

{% block extrahead %}{{ block.super }}
<script type="text/javascript" src="{{media_url}}js/jquery.js"></script>
    <script type="text/javascript">
{% if form.error_dict %}
function satchmo_find(inputs, id) {
	for (var i=0; i<inputs.length; i++) { 
		var elt = inputs[i];
		if (elt.id == id) {
			return elt;
		}
	}
	return null;
}
function satchmo_update(inputs, id, msg) {
	var elt = satchmo_find(inputs, "id_" + id);
	if (elt) {
		$(elt).after("<span class='error'>**" + msg + "</span>");
	}
}
$(function() {
	var inputs = $('input');
	{% for key,msg in form.error_dict.items %}
	satchmo_update(inputs, "{{key}}", "{{msg.0}}");{% endfor %}
});
{% endif %}
</script>
{% endblock %}